import request from "@/utils/request.js";

const url = '/cloud-sys-service/sys-org'

/**
 * 获取组织列表
 */
export function list(data) {
	return request({
		url: url + "/list",
		method: "post",
		data
	});
}

/**
 * 新增或修改组织
 */
export function save(data) {
	return request({
		url: url + "/save",
		method: "post",
		data
	});
}

/**
 * 删除组织
 */
export function remove(id) {
	return request({
		url: url + `/remove/${id}`,
		method: "get",
	});
}

/**
 * 获取组织下拉列表
 */
export function listOrgOptions(params) {
	return request({
		url: url + "/listOrgOptions",
		method: "get",
		params
	});
}

/**
 * 下载导入模板
 */
export function downloadTemplate() {
	return request({
		url: url + `/downloadTemplate`,
		method: "get",
		responseType:'blob'
	});
}

/**
 * 导入
 */
export function importExcel(params) {
	return request({
		url: url + `/downloadTemplate`,
		method: "get",
		params
	})
}


// 列表相关列信息
export const columnInfo = [
	{
		"title":"机构名称",
		"field":"name",
		"fixed":"left",
		"align":"left",
		"headerAlign": "center",
		"treeNode":true,
		"minWidth":"200"
	},
	{
		"title":"机构编号",
		"field":"uniqueCode",
		"fixed":"left",
		"align":"center",
		"minWidth":"150"
	},
	{
		"title":"上级机构",
		"field":"parentName",
		"align":"center",
		"minWidth":"200"
	},
	{
		"title":"状态",
		"field":"status",
		"align":"center",
		"proxyColumn":true,
		"width":"80"
	},
	{
		"title":"排序",
		"field":"sort",
		"align":"center",
		"width":"80"
	},
	{
		"title":"操作",
		"operate":"true",
		"minWidth":"220px",
		"options":[
			{
				"text":true,
				"btnName":"新增",
				"type":"primary",
				"icon":"Edit",
				"method":"showAddDialog"
			},
			{
				"text":true,
				"btnName":"编辑",
				"type":"primary",
				"icon":"Edit",
				"method":"showFormDialog"
			},
			{
				"text":true,
				"btnName":"删除",
				"type":"primary",
				"icon":"Delete",
				"method":"showRemoveDialog",
				"color":"#ff4949"
			}
		]
	}
]
